mini.parse();
var projectName = $("#projectName").val();
var form = new mini.Form("form1");

function SaveDataReportLoseBarcode() {
	form.validate();
	if (form.isValid() == false)
		return;
	var json = mini.encode(GetDataReportLoseBarcode());
	mini.mask({
        el: document.body,
        cls: 'mini-mask-loading',
        html: '正在保存信息...'
    }); 
	$.ajax({
		url : projectName+"/ReportLoseBarcodeAdmin/saveReportLoseBarcode",
		type : 'post',
		contentType : "application/json; charset=utf-8",
		dataType : 'json',
		data : json,
		cache : false,
		success : function(data) {
			mini.unmask();
			if (data.status == '1') {
				mini.alert(data.message, "" , function() {
					CloseWindowReportLoseBarcode("save");
				});
			} else if(data.status == '0') {
				mini.alert(data.message);
			} else {
				mini.alert("发生错误!");
			}
		},
		error : function(jqXHR, textStatus, errorThrown) {
		    mini.unmask();
			mini.alert(jqXHR.responseText);
			CloseWindowReportLoseBarcode();
		}
	});
}

////////////////////
//标准方法接口定义
function CheckEventReportLoseBarcode(data) {
//跨页面传递的数据对象，克隆后才可以安全使用
	data = mini.clone(data);
	if (data.action == "edit") {
		SetDataReportLoseBarcode(data);
	} else if (data.action == "new") {
	}else if(data.action =="look"){
		SetDataReportLoseBarcode(data);
		readOnlyForm();
	}
}

function GetDataReportLoseBarcode(){
	var o = form.getData();
	return o;
}
function SetDataReportLoseBarcode(data){
		$.ajax({
			url : projectName+"/ReportLoseBarcodeAdmin/queryByID?id="
					+ data.id,
			cache : false,
			success : function(text) {
				var o = mini.decode(text);
				form.setData(o);
				form.setChanged(false);
			}
			});
}
function CloseWindowReportLoseBarcode(action) {
	if (action == "close" && form.isChanged()) {
		if (confirm("数据被修改了，是否先保存？")) {
			return false;
		}
	}
	if (window.CloseOwnerWindow)
		return window.CloseOwnerWindow(action);
	else
		window.close();
}
function onOkReportLoseBarcode(e) {
	SaveDataReportLoseBarcode();
}
function onCancelReportLoseBarcode(e) {
	CloseWindowReportLoseBarcode("cancel");
}

function labelModel() {
	var fields = form.getFields();
	for ( var i = 0, l = fields.length; i < l; i++) {
		var c = fields[i];
		if (c.setReadOnly)
			c.setReadOnly(true); //只读
		if (c.setIsValid)
			c.setIsValid(true); //去除错误提示
		if (c.addCls)
			c.addCls("asLabel"); //增加asLabel外观
	}
}
function inputModel() {
	var fields = form.getFields();
	for ( var i = 0, l = fields.length; i < l; i++) {
		var c = fields[i];
		if (c.setReadOnly)
			c.setReadOnly(false);
		if (c.removeCls)
			c.removeCls("asLabel");
	}
	mini.repaint(document.body);
}
function readOnlyForm(){
	$("#button_okReportLoseBarcode").hide();
	$("#button_onCancelReportLoseBarcode").hide();
	form.setEnabled(false);
}